Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ask to press return at the end of showing help on non-Windows platforms #957

Merged
merged 3 commits into from
Feb 29, 2024

Conversation

gary-sweet
Copy link
Contributor

Description

Having to press return at the end of listing the samples or showing the help has been pretty annoying.
I suspect it's there for Windows users primarily to prevent to command window closing.
It was already excluded on Android platforms, I've also now excluded it on Linux platforms.

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

It's been irritating me for a while now.
Copy link
Collaborator

@tomadamatkinson tomadamatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your right. This was there for the windows prompt

LGTM

@gary-sweet
Copy link
Contributor Author

I think your right. This was there for the windows prompt

Should I change it only display on Windows in that case, and not for any other platform?

@tomadamatkinson
Copy link
Collaborator

Actually yes that would be a better fix @gary-sweet

@gary-sweet gary-sweet changed the title Don't ask to press return at the end of showing help on Linux platforms Don't ask to press return at the end of showing help on non-Windows platforms Feb 28, 2024
@SaschaWillems
Copy link
Collaborator

SaschaWillems commented Feb 28, 2024

Can we extend this to "Don't ask to press return at the end of showing help on terminals"? This might be fine if you run the binary from e.g. the explorer, but it's acting very weird if you run it from e.g. Windows terminal. You need to press a key after the help shows up, and the terminal prompt is then continuing in the middle of nowhere:

image

@gary-sweet
Copy link
Contributor Author

Can we extend this to "Don't ask to press return at the end of showing help on terminals"? This might be fine if you run the binary from e.g. the explorer, but it's acting very weird if you run it from e.g. Windows terminal. You need to press a key after the help shows up, and the terminal prompt is then continuing in the middle of nowhere:

I'm not sure how anything I've changed here can affect this. The same code should be running on Windows platforms as it always was.

@SaschaWillems
Copy link
Collaborator

Sorry, should've noted that this was caused by the change in #956. I think if we remove the key press requirement on Windows too, the odd behaviour goes away.

@asuessenbach
Copy link
Contributor

asuessenbach commented Feb 29, 2024

Can we extend this to "Don't ask to press return at the end of showing help on terminals"?

To make it a bit more complex, this seems to depend on the terminal! I get different behaviours on different terminals (on Win10):

  • with the simple command window, I have to enter return, no matter if std::cin.get() is called or not! But the next prompt is right after the help-output.
  • with the PowerShell, I also have to enter return, no matter if std::cin.get() is called. And the next prompt is right after the previous prompt. That is: at the beginning of the help text!
  • with a bash terminal, if std::cin.get() is not called, everything is as expected: you don't need to enter any key and the next prompt is right after the help-output.

That is, even though it seems you could reliably determine if the program has been started from any of those terminals, due to their different and partly strange behaviours it doesn't seem to be worth to make it so.

HWND consoleWnd = GetConsoleWindow();
DWORD consoleProcessId;
GetWindowThreadProcessId(consoleWnd, &consoleProcessId);
if (GetCurrentProcessId() == consoleProcessId)

@gary-sweet
Copy link
Contributor Author

I can't test anything on Windows, so if we believe this needs a different behaviour there I'm afraid someone else will have to implement it. I don't see any reason that should prevent this PR going ahead though - any further change can be done on top of it.

@SaschaWillems
Copy link
Collaborator

SaschaWillems commented Feb 29, 2024

You're correct. Let's move the Windows related discussion to the PR or a new issue. Sorry for the noise.

@SaschaWillems SaschaWillems self-requested a review February 29, 2024 08:45
@gary-sweet gary-sweet merged commit 478890b into KhronosGroup:main Feb 29, 2024
25 checks passed
@gary-sweet gary-sweet deleted the no-press-return branch February 29, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants